#!/usr/bin/python

import sys
from Bio.SeqIO.QualityIO import FastqGeneralIterator

untrimmed = sys.argv[1]
trimmed = sys.argv[2]

handle = open(trimmed, "w")
min_length = 10
for title, seq, qual in FastqGeneralIterator(open(untrimmed)) :
    qual = qual.rstrip("B") #Remove any trailing B characters
    length = len(qual)
    if length >= min_length:
        seq = seq[:length] #trim to match
        handle.write("@%s\n%s\n+\n%s\n" % (title, seq, qual))
handle.close()
